package interview.java.q2.internal;

public class MatrixBorderFiller {

  public MatrixBorderFiller(String[][] matrix, String fillStr, int startRow, int startCol) {
    _matrix = matrix;
    _fillStr = fillStr;
    _startRow = startRow;
    _startCol = startCol;
  }

  public void fillRow() {
    String[] line = _matrix[_startRow < 0 ? _matrix.length + _startRow : _startRow];
    for (int j = _startCol; j < line.length - _startCol; j++) {
      line[j] = _fillStr;
    }
  }

  public void fillColumn() {
    for (int i = _startRow; i < _matrix.length - _startRow; i++) {
      String[] line = _matrix[i];
      line[_startCol < 0 ? line.length + _startCol : _startCol] = _fillStr;
    }
  }

  private final String[][] _matrix;
  private final String _fillStr;

  private final int _startRow;
  private final int _startCol;
}
